
<template>
<div>
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="坐席客服" name="first">
      <el-form :inline="true" :model="formInlineA" class="demo-form-inline">
        <el-form-item label="关键字">
          <el-input v-model="formInlineA.user" placeholder="关键字"></el-input>
        </el-form-item>
        <el-form-item label="管理身份">
          <el-select v-model="value" placeholder="全部">
            <el-option
              v-for="item in formInlineA.region"
              :key="item.paramValue"
              :label="item.paramName"
              :value="item.paramValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="statusValue" placeholder="全部">
            <el-option
              v-for="item in formInlineA.status"
              :key="item.paramValue"
              :label="item.paramName"
              :value="item.paramValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="sear_btnbox">
          <el-button type="primary" icon="el-icon-search" @click="onSubmitA">查询</el-button>
          <el-button type="success" icon="el-icon-circle-plus-outline" @click="onAddA('formName')">添加</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :data="coustomerTable"
        stripe
        border
        style="width: 100%"
        v-loading="loading">
        <el-table-column
          type='index'
          label="序号"
          align='center'
          width="50">
        </el-table-column>
        <el-table-column
          prop="name"
          label="客服姓名"
          width="120">
        </el-table-column>
        <el-table-column
          prop="account"
          label="账号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="userId"
          label="工号"
          width="120">
        </el-table-column>
        <el-table-column
          prop="isAdmin"
          label="管理身份">
        </el-table-column>
         <el-table-column
          prop="statusName"
          label="状态">
        </el-table-column>
        <el-table-column
          fixed='right'
          width="140"
          align='center'
          label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
              <el-button
                type="warning"
                size="mini"
                @click="handleEditStop(scope.$index, scope.row)">启用/停用</el-button>
            </template>
        </el-table-column>
      </el-table>

      
      <div class="block">
        <el-pagination
          @size-change="handleSizeChangeFirst"
          @current-change="handleCurrentChangeFirst"
          :current-page.sync="currentPageFirst"
          :page-sizes="[5, 10, 20, 30]"
          :page-size="pageSizeFirst"
           layout="sizes, prev, pager, next"    
          :total="totalFirst">
        </el-pagination>
      </div>

    </el-tab-pane>
    <el-tab-pane label="业务支持" name="second">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="关键字">
          <el-input v-model="formInline.user" placeholder="关键字"></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="statusVal" placeholder="全部">
            <el-option
              v-for="item in formInlineA.status"
              :key="item.paramValue"
              :label="item.paramName"
              :value="item.paramValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="sear_btnbox">
          <el-button type="primary" icon="el-icon-search" @click="onSubmitB">查询</el-button>
          <el-button type="success" icon="el-icon-circle-plus-outline" @click="onAddB('form')">添加</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :data="businessTable"
        stripe
        border
        style="width: 100%"
        v-loading="loading">
        <el-table-column
          type='index'
          label="序号"
          align='center'
          width="50">
        </el-table-column>
        <el-table-column
          prop="name"
          label="客服姓名"
          width="120">
        </el-table-column>
        <el-table-column
          prop="account"
          label="账号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="phone"
          label="手机"
          width="120">
        </el-table-column>
        <el-table-column
          prop="equipmentCompanyName"
          label="所属公司"
          min-width='200'>
        </el-table-column>
         <el-table-column
          prop="statusName"
          label="状态">
        </el-table-column>
        <el-table-column
          fixed='right'
          width="140"
          align='center'
          label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="buinssEdit(scope.$index, scope.row)">编辑</el-button>
              <el-button
                type="warning"
                size="mini"
                @click="handleEditStop(scope.$index, scope.row)">启用/停用</el-button>
            </template>
        </el-table-column>
      </el-table>


       <div class="block">
        <el-pagination
          @size-change="handleSizeChangeSecond"
          @current-change="handleCurrentChangeSecond"
          :current-page.sync="currentPageSecond"
          :page-sizes="[5, 10, 20, 30]"
          :page-size="pageSizeSecond"
           layout="sizes, prev, pager, next"    
          :total="totalSecond">
        </el-pagination>
      </div>

    </el-tab-pane>
   </el-tabs>
   <!-- gm添加坐席gm -->
    <el-dialog :title="sitTitle"  :visible.sync="dialogaddzx" center width="600px" :close-on-click-modal="false" :show-close="false">
      <el-form :model="formName" :rules="rules2" ref="formName" label-width="100px">
        <el-form-item label="姓名">
          <el-input key="zxname" type="text" autocomplete="off" v-model="formName.name"></el-input>
        </el-form-item>
         <el-form-item label="登录账号" prop="account" >
          <el-input  key="acconut" type="text" autocomplete="off" v-model="formName.account" @blur="onBlur(formName.account)" :disabled="flag? true: false "></el-input>
        </el-form-item>
        <el-form-item label="管理身份" >
          <el-radio-group v-model="formName.isAdmin">
            <el-radio :label="2">是</el-radio>
            <el-radio :label="1">否</el-radio>
          </el-radio-group>
          <div class="text"><span>*</span>  设为管理身份，该人员将会有更多权限</div>
        </el-form-item>
        <el-form-item label="是否修改密码" v-if="flag">
          <el-radio-group v-model="formName.isCheckPassword" @change="changeVal(formName.isCheckPassword)">
            <el-radio :label="0">修改</el-radio>
            <el-radio :label="1">不修改</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="登录密码" prop="password" v-if="passwordFlag">
          <el-input  key="accontpass" type="password" autocomplete="off" v-model="formName.password"></el-input>
        </el-form-item>

       
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelEvent('formName')">取 消</el-button>
        <el-button type="primary" @click="onAddTrueBtn('formName')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- gm添加业务支持gm -->
    <el-dialog :title="businessTitle" 
               :visible.sync="dialogaddyw"
               center 
               width="600px" 
               :close-on-click-modal="false" 
               :show-close="false">
      <el-form :model="form" :rules="rules2" ref="form" label-width="100px">
        <el-form-item label="设备公司">
          <el-select v-model="equipmentCompanyLabel" clearable filterable placeholder="请选择设备公司">
           <el-option 
                v-for="(item,index) in equipmentCompany"
            :key="index"
            :label="item.equipmentCompanyName"
            :value="item.equipmentCompanyId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="newCompanyShow" class="newCompanyTips" label="">没有找到公司信息前往设备公司信息进行添加?<el-button size="small" @click="newCompanyShowBtn">立即前往</el-button></el-form-item>
        <el-form-item label="账号" prop="account">
          <el-input key="passwordtext" type="text" autocomplete="off" v-model="form.account" @blur='onBlur(form.account)'></el-input>
        </el-form-item>
        <el-form-item label="是否修改密码" v-if="isShow">
          <el-radio-group v-model="form.isCheckPassword" @change="changeShow(form.isCheckPassword)">
            <el-radio :label="0">修改</el-radio>
            <el-radio :label="1">不修改</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="用户密码" prop="password" v-if="isShowPassword">
          <el-input  key="newpdtext" type="password" autocomplete="off" v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item label="用户姓名">
          <el-input key="agnewpdtext" type="text" autocomplete="off" v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="用户电话" prop="phone">
          <el-input key="agnewpdtext" type="text" autocomplete="off" v-model="form.phone"></el-input>
        </el-form-item>
        
        <!-- <el-form-item label="新增设备公司" v-if="newCompanyShow">
          <el-input key="agnewpdtext" type="text" autocomplete="off" v-model="form.equipmentCompanyId"></el-input>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelEvent('form')">取 消</el-button>
        <el-button type="primary" @click="ywTrueBtn('form')">确 定</el-button>
      </div>
    </el-dialog>

    <!-- gm是否启用gm -->
    <el-dialog title="是否启用" 
               :visible.sync="dialogstart" 
               center 
               width="400px" 
               :close-on-click-modal="false"
               :show-close="false">
      <el-form :model="form" label-width="100px">
        <el-form-item label="是否启用坐席" >
           <el-radio-group v-model="work_start">
              <el-radio :label="0">启用</el-radio>
              <el-radio :label="1">停用</el-radio>
           </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogstart = false">取 消</el-button>
        <el-button type="primary" @click="workStartBtn">确 定</el-button>
      </div>
    </el-dialog>



 </div>
</template>
<script>
import bus from '@/api/bus'
import { 
  getUserServiceStaffList, 
  saveUserServiceStaff, 
  checkAccount, 
  updateUserServiceStaff, 
  updateUserServiceStaffState,
  getBusinessPersonnelByQuery,
  saveBusinessPersonnel,
  updateBusinessPersonnelState,
  updateBusinessPersonnel, 
  getEquipmentCompanyList, 
  saveEquipmentCompany } from '@/api'
  export default {
    data() {
      const validateAccount = (rule, value, callback) => {
        let reg = /\w{6,16}/;
        if (value != '' && reg.test(value)) {
          callback()
        } else {
          callback(new Error('账号必须为6-16位数字、字母及下划线'));
        }
      };
      const validatePassword = (rule, value, callback) => {
        // let reg = /[\w\d_]{6,16}/;
        let reg = /[\u4E00-\u9FA5A-Za-z0-9_]{6,16}/;
        if (value != '' && reg.test(value)) {
          callback()
        } else {
          callback(new Error('密码必须为6-16位数字、字母及下划线'))
        }
      };
      const validatePhone = (rule, value, callback) => {
        let reg = /^1[345789]\d{9}$/;
        if (value != '' && reg.test(value)) {
          callback()
        } else {
          callback(new Error('请输入正确的手机号'))
        }
      }
      return {
        equipmentCompanyChoose:'',
        newCompanyShow:1,//是否显示新增公司
        roleId:'',
        tabGroup: true, // true坐席 false业务
        errorMsg: null,
        isAdd: null, // 坐席  0添加/1修改
        isAddB: null, // 业务   1添加/2修改
        flag: false, 
        passwordFlag: true,
        userId: null, // row id
        status: null, // row状态
        work_start: null,//是否启用
        ywUserId: null, // row 业务id
        ywStatus: null, // row 业务状态
        isShow: null, // 业务 密码添加提示
        isShowPassword: null, // 业务 密码框是否显示
        totalSecond: null, // 业务 总条数
        totalFirst: null, // 坐席 总条数
        loading: true, 
        currentPageFirst: 1, // 坐席 当前页
        currentPageSecond: 1, // 业务 当前页
        pageSizeSecond: 10, // 业务 每页条数
        pageSizeFirst: 10, // 坐席 每页条数
        sitTitle: '', // 坐席添加/修改标题
        businessTitle: '', // 业务添加/修改标题
        value: '', // 管理身份编号
        statusValue: '', //停启用编号
        statusVal: '', // 业务停启用编号
        form: {
          account: '',
          password: '',
          name: '',
          phone: '',
          equipmentCompanyId: '',
          isCheckPassword: 1, // 不修改
        },
        equipmentCompany:[],
        equipmentCompanyLabel:'',
        activeName: 'first',//tabs激活态
        formInlineA: {
          user: '',
          region: [],
          status: []
        },
        formInline: {//查询条件
          user: '',
          region: ''
        },
        coustomerTable: [],
        businessTable: [],
        dialogaddzx:false,
        dialogpassset:false,
        dialogstart:false,
        dialogaddyw:false,
        dialogdele:false,
        formName: {
          name: '',
          account:"",
          password:"",
          accontpass:"",
          isAdmin: 1, // 1不是管理员  2  管理员
          isCheckPassword: 1 // 1不修改 0 修改
        },
        rules2: {
          account: [{
            validator: validateAccount,
            trigger: 'change'
          }],
          password:[{
            validator: validatePassword,
            trigger: 'change'
          }],
          phone: [{
            validator: validatePhone,
            trigger: 'change'
          }],
        }
      };
    },
    created () {
      let dictionaryValue = JSON.parse(sessionStorage.getItem('dictionaryValue'))
      let region = []
      dictionaryValue.map((item, index) => {
        if(item.typeValue == 'role') {
          item.paramParamList.map((item, index) => {
            if(item.paramName !='超级管理员' && item.paramName != '业务支持人员') {
              region.push(item)
            }
          })
          this.formInlineA.region = region
        }
        if(item.typeValue == 'user_type') {
          this.formInlineA.status = item.paramParamList
        }
      })
      let params = {
        Query: this.formInlineA.user, //关键字
        IsAdmin: this.value, //是否管理员
        status: this.statusValue, //状态
        page: this.currentPageFirst, //当前页面
        size: this.pageSizeFirst//每页显示个数 
      }
      this.UserServiceStaffList(params)
    },
    methods: {
      clearValidate(formName) {
        this.$refs[formName].clearValidate();
      },
      getEquipmentCompanyList(params){ //查询设备公司信息
         getEquipmentCompanyList (params).then(res => {
          let code = res.data.code
          if (code == 0) {
            let dataList = res.data.data.list;
            this.equipmentCompany = res.data.data.list
          }else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
          } 
        }) 
      },
      newCompanyShowBtn(){ //添加设备公司信息
        //this.newCompanyShow = 1;
        this.$router.push('/home/equipmentcompany')
      },
      handleClick(tab, event) {  //tab切换的大选项卡
        let tabGroup = tab.name
        if(tabGroup == 'first') { // 坐席
          let params = {
            Query: this.formInlineA.user, //关键字
            IsAdmin: this.value, //是否管理员
            status: this.statusValue, //状态
            page: this.currentPageFirst, //当前页面
            size: this.pageSizeFirst//每页显示个数 
          }
          this.tabGroup = true
          this.UserServiceStaffList(params)
        } else if(tabGroup == 'second') { // 业务
          let params = {
            Query: this.formInline.user,
            status: this.statusVal,
            page: this.currentPageSecond,
            size: this.pageSizeSecond
          }
          this.tabGroup = false
          this.getBusinessPersonnelByQuery(params) //查询业务人员
        }
      },
      changeVal(key){
        this.formName.isCheckPassword = key
        if (key == 0) {
          this.passwordFlag = true;
        } else if (key == 1) {
          this.passwordFlag = false
        }
      },
      changeShow(key){
        this.form.isCheckPassword = key
        if(key == 0) {
          this.isShowPassword = true
        } else if (key == 1) {
          this.isShowPassword = false
        }
      },
      //坐席 改变每页的条数
      handleSizeChangeFirst (val) {
        this.pageSizeFirst = val
        this.currentPageFirst = 1
        let params = {
          Query: this.formInlineA.user,
          IsAdmin: this.value,
          status: this.statusValue,
          page: this.currentPageFirst,
          size: this.pageSizeFirst
        }
        this.UserServiceStaffList(params)
      },
      //坐席 改变当前页
      handleCurrentChangeFirst(val) {
        this.currentPageFirst = val
        let params = {
          Query: this.formInlineA.user,
          IsAdmin: this.value,
          status: this.statusValue,
          page: this.currentPageFirst,
          size: this.pageSizeFirst
        }
        this.UserServiceStaffList(params)
      },
      // 业务 每页条数
      handleSizeChangeSecond (val) {
        this.pageSizeSecond = val
        this.currentPageSecond = 1
        let params = {
          Query: this.formInline.user,
          status: this.statusVal,
          page: this.currentPageSecond,
          size: this.pageSizeSecond
        }
        this.getBusinessPersonnelByQuery(params)
      },
      // 业务  改变页码
      handleCurrentChangeSecond(val) {
        this.currentPageSecond = val
        let params = {
          Query: this.formInline.user,
          status: this.statusVal,
          page: this.currentPageSecond,
          size: this.pageSizeSecond
        }
        this.getBusinessPersonnelByQuery(params)
      },
      //查询按钮
      onSubmitA() {
        if (this.loading) {
          return
        }
        this.loading = true
        let params = {
          Query: this.formInlineA.user, //关键字
          IsAdmin: this.value, //是否管理员
          status: this.statusValue, //状态
          pages: this.currentPageFirst, //当前页面
          size: this.pageSizeFirst //每页显示个数 
        }
        this.UserServiceStaffList(params)
      },
      // 添加按钮
      onAddA(formName){
        this.flag = false
        this.passwordFlag = true
        this.dialogaddzx=true
        this.formName = {
          name: '',
          account:"",
          password:"",
          accontpass:"",
          isAdmin:1
        },
        this.isAdd = 0 
        this.sitTitle = '添加坐席客服人员'
        // this.clearValidate(formName); 
        this.$refs[formName].resetFields()//删除表单验证
      },
      //提交
      onAddTrueBtn (formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.currentPageFirst = 1
            this.pageSizeFirst = 10
            if (this.isAdd == 0) {//添加
              let params = {
                name: this.formName.name,
                password: this.formName.password,
                account: this.formName.account,
                isAdmin: this.formName.isAdmin,
              }
              this.UserServiceStaff(params)
              this.dialogaddzx = false
              console.log(params)
            } else if (this.isAdd == 1) { //编辑
              let params = {
                userId: this.userId,
                name: this.formName.name,
                account: this.formName.account,
                isAdmin: this.formName.isAdmin,
                isCheckPassword: this.formName.isCheckPassword,
                password: this.formName.password
              }
              console.log(params)
              this.updateUserServiceStaff(params)
              this.dialogaddyw = false
            }
          } else {
            //console.log('error submit!!');
					  return false;
          }
        })
        //this.$refs[formName].resetFields()
      },
      //停启用确定
      workStartBtn() {
        if (this.tabGroup) { // 坐席
          let params = {
            id: this.userId,
            status: this.work_start
          }
          this.updateUserServiceStaffState(params)
        } else { // 业务
          let params = {
            id: this.ywUserId,
            status: this.work_start
          }
          this.updateBusinessPersonnelState(params)
        }
      },
      //业务人员   添加按钮
      onAddB(formName){
        this.newCompanyShow = 1;//不显示新增设备公司
        this.isAddB = 1
        this.businessTitle = '添加业务支持人员'
        this.isShow = false
        this.isShowPassword = true
        this.dialogaddyw = true
        this.form = {
          account: '',
          password: '',
          name: '',
          phone: '',
          equipmentCompanyId: '',
          isCheckPassword: 1 // 不修改
        }
        this.equipmentCompanyLabel =''
       let paramsEqui ={
          query:'',
          size:'99999',
          page:'1'
        }
        this.getEquipmentCompanyList(paramsEqui)
        // this.clearValidate(formName);
        this.$refs[formName].resetFields() //删除表单验证
      },
      //业务人员    添加/修改确定按钮
      ywTrueBtn(formName){
        this.$refs['form'].validate((valid) => {
          if (valid) {
            this.currentPageSecond = 1
            this.pageSizeSecond = 10
            if(this.isAddB == 1) { // 添加
              let params = {
                account: this.form.account,
                password: this.form.password,
                name: this.form.name,
                phone: this.form.phone,
                equipmentCompanyId: this.equipmentCompanyLabel//修改公司id
              }
              this.saveBusinessPersonnel(params)
            } else if(this.isAddB == 2) { // 编辑
              let params = {
                operationUserId: this.ywUserId,
                account: this.form.account,
                name:this.form.name,
                phone:this.form.phone,
                equipmentCompanyId:this.equipmentCompanyLabel,
                isCheckPassword:this.form.isCheckPassword,
                password: this.form.password
              }
              //console.log(params)
              this.updateBusinessPersonnel(params)
            }
          } else {
            //console.log('error submit!!');
            return false;
          }
        })
        //this.$refs[formName].resetFields()
      },
      //业务  查询按钮
      onSubmitB(){
        if (this.loading) {
          return
        }
        this.loading = true
        let params = {
          Query: this.formInline.user,
          status: this.statusVal,
          page: this.currentPageSecond,
          size: this.pageSizeSecond
        }
        this.getBusinessPersonnelByQuery(params)
      },
      //验证账号
      onBlur(account) {
        let params = {
          account: account,
          type: 0
        }
        checkAccount(params).then(res => {
          let code = res.data.code
          if(code == 1) {
            this.$message({
              message: res.data.msg
            });
            //校验账号存在不清空账号
            // this.formName.account = ''
            // this.form.account = ''
          }
        })
      },
      //对整个表单进行重置
      // 取消按钮
      cancelEvent (formName) {
        this.dialogaddzx = false
        this.dialogaddyw = false
        this.$refs[formName].resetFields()
      },
      //添加
      UserServiceStaff (params) {
        saveUserServiceStaff (params).then(res => {
          let code = res.data.code
          if (code == 1) {
            this.$message({
              message: res.data.msg
            })
            this.dialogaddzx = true
          } else if (code == 0) {
            this.UserServiceStaffList({
              Query: this.formInlineA.user, //关键字
              IsAdmin: this.value, //是否管理员
              status: this.statusValue, //状态
              page: this.currentPageFirst, //当前页面
              size: this.pageSizeFirst//每页显示个数 
            })
            this.dialogaddzx = false
          }
        })
      },
      //修改
      updateUserServiceStaff (params) {
        updateUserServiceStaff(params).then(res => {
          let code = res.data.code
          if (code == 1) {
            this.$message({
              message: res.data.msg
            })
            this.dialogaddzx = true
          } else if(code == 0) {
             this.UserServiceStaffList({
              Query: this.formInlineA.user, //关键字
              IsAdmin: this.value, //是否管理员
              status: this.statusValue, //状态
              page: this.currentPageFirst, //当前页面
              size: this.pageSizeFirst//每页显示个数 
            })
            this.dialogaddzx = false
          }
        })
      },
      //查询
      UserServiceStaffList(params) {
        getUserServiceStaffList(params).then(res => {
          let code = res.data.code
          if (code == 0) {
            let data = res.data.data
            //console.log(data)
            this.coustomerTable = data.list
            this.totalFirst = data.pageInfo.total
            this.loading = false
          } else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
          }
        })
      },
      //启停
      updateUserServiceStaffState (params) {
        updateUserServiceStaffState(params).then(res => {
          let code = res.data.code
          if(code == 0) {
            this.UserServiceStaffList({
              Query: this.formInlineA.user, //关键字
              IsAdmin: this.value, //是否管理员
              status: this.statusValue, //状态
              page: this.currentPageFirst, //当前页面
              size: this.pageSizeFirst//每页显示个数 
            })
            this.dialogstart = false
          } else if (code == 1) {
             this.$message({
              message: res.data.msg
            })
            this.dialogstart = true
          }
        })
      },
      //业务人员   查询
      getBusinessPersonnelByQuery(params){
        getBusinessPersonnelByQuery(params).then(res => {
          let code  = res.data.code
          if (code == 0) {
            let data = res.data.data
            this.businessTable = data.list
            this.totalSecond = data.pageInfo.total
            this.loading = false
          } else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
          }
        })
      },
      //业务人员   添加
      saveBusinessPersonnel(params) {
        saveBusinessPersonnel(params).then(res => {
          let code = res.data.code
          if(code == 0) {
            this.dialogaddyw = false
            let params = {
              Query: this.formInline.user,
              status: this.statusVal,
              page: this.currentPageSecond,
              size: this.pageSizeSecond
            }
            this.getBusinessPersonnelByQuery(params)
          } else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
          }
        })
      },
      // 业务  修改
      updateBusinessPersonnel(params){
        updateBusinessPersonnel(params).then(res => {
          let code = res.data.code
          if(code == 0) {
            //console.log(res.data)
            let params = {
              Query: this.formInline.user,
              status: this.statusVal,
              page: this.currentPageSecond,
              size: this.pageSizeSecond
            }
            this.getBusinessPersonnelByQuery(params)
           this.dialogaddyw = false
          } else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
            this.dialogaddyw = true
          }
        })
      },
      //业务   启停
      updateBusinessPersonnelState(params) {
        updateBusinessPersonnelState(params).then(res => {
          let code = res.data.code
          if (code == 0) {
            let params = {
              Query: this.formInline.user,
              status: this.statusVal,
              page: this.currentPageSecond,
              size: this.pageSizeSecond
            }
            this.getBusinessPersonnelByQuery(params)
            this.dialogstart = false
          } else if (code == 1) {
            this.$message({
              message: res.data.msg
            })
            this.dialogstart = true
          }
        })
      },
      buinssEdit(index,row){//业务支持编辑
        this.form.account = row.account
        this.form.name = row.name
        this.form.phone = row.phone
        this.ywUserId = row.operationUserId
        this.equipmentCompanyLabel = row.equipmentCompanyId
        this.isAddB = 2
        this.businessTitle = '编辑业务支持人员'
        this.isShow = true
        this.isShowPassword = false
        this.dialogaddyw = true
        this.form.isCheckPassword= 1 //编辑进入的时候默认不修改
        this.newCompanyShow =0;//不显示新增公司提示
        //console.log(this.equipmentCompanyLabel)
        let paramsEqui ={
          query: '',
          size:'99999',
          page:'1'
        }
        this.getEquipmentCompanyList(paramsEqui)
        this.$refs['form'].resetFields()
      },
      handleEdit(index, row) {//客服编辑
        this.isAdd = 1
         this.sitTitle = '编辑坐席客服人员'
        this.flag = true;
        this.passwordFlag = false;
        this.userId = row.userId
        this.formName = {
          name: row.name,
          account: row.account,
          password: row.password,
          isAdmin: row.roleId,
          isCheckPassword: 1
        },
        //console.log(row)
        this.dialogaddzx=true
        this.$refs['formName'].resetFields()
      },
      handleEditStop(index, row) {//启用停用
        this.work_start = row.status
        this.userId = row.userId
        this.ywUserId = row.operationUserId
        this.ywStatus = row.status
        this.dialogstart=true
      }
    }
  };
</script>
<style scoped>
  .el-tabs{padding:0 10px;}
  .text{
    margin-top: -10px;
    margin-bottom: -13px;
    font-size: 12px;
    color: #ccc; 
  }
  span{
    color: red;
  }
  .el-select{width:450px;}
  .newCompanyTips{
    font-size:12px;
    line-height:28px;
    margin:-20px 0 5px;
    color:#c50606;}
</style>